package com.foxzzz.two.pointers;


public class Solution26 {
    public int removeDuplicates(int[] nums) {
        if (nums.length <= 1) {
            return nums.length;
        }
        int i = 0;
        for (int j = i; j < nums.length; j++) {
            if (nums[j] != nums[i]) {
                nums[++i] = nums[j];
            }
        }
        return i + 1;
    }

    public static void main(String[] args) {
        System.out.println(new Solution26().removeDuplicates(new int[]{1,1,2}));
        System.out.println(new Solution26().removeDuplicates(new int[]{0,0,1,1,1,2,2,3,3,4}));
    }
}
